package com.xiaobange.controller.app;

import com.xiaobange.entity.Reservation;
import com.xiaobange.service.ReservationService;
import com.xiaobange.vo.ResultResponse;
import jakarta.validation.Valid;
import jakarta.websocket.server.PathParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version 1.0
 * @Author 小班哥
 * @Date 2025/5/11 12:27
 * @Explain 挂号预约接口
 */
@RestController
@RequestMapping("/app/reservation")
public class AppReservationController {

    @Autowired
    private ReservationService reservationService;

    /**
     * 添加挂号订单
     * @param reservation 挂号信息
     * @return 挂号结果
     */
    @PostMapping("/add")
    public ResultResponse<String> registered(@Valid @RequestBody Reservation reservation){
        return reservationService.addRegisteredOrder(reservation);
    }


    /**
     * 修改预约状态
     * @param status 状态值
     * @param reservationId 取消数据编号
     * @return
     */
    @DeleteMapping("/updateStatus")
    public ResultResponse<?> close(@PathParam("status")String status,@PathParam("reservationId") String reservationId){
        return reservationService.cancel(status,reservationId);
    }

    /**
     * 修改预约数据
     * @param reservation
     * @return
     */
    @PostMapping("modify")
    public ResultResponse<?> modify(@RequestBody Reservation reservation){
        return reservationService.modify(reservation);
    }

    /**
     * 查询用户的预约记录
     * @param clientId 用户ID
     * @param status 预约状态
     * @return 预约数据
     */
    @GetMapping("/query")
    public ResultResponse<List<Reservation>> query(@PathParam("clientId") String clientId,@PathParam("status") String status){
        return reservationService.queryStatus(clientId,status);
    }
}
